<template>
	<view>
		
		<!-- 内容 -->
		<view class="combodybj overflow">
			<view v-show="flag1">
				<!-- 添加银行卡 -->
				<view class="bgdfff addCard" @click="addCard">+添加银行卡</view>
			</view>
			<!-- 绑定后状态 -->
			<view v-show="!flag1" class='bgdfff box'>
				<view class="name font32 colorcdc">			
					<view>银行名称</view>
					<view>{{userName}}</view>
				</view>
				<view class="name font32 colorcdc">			
					<view>银行账号</view>
					<view>{{userNumber}}</view>
				</view>
				
				
				<view class="name font32 colorcdc" style="padding-left:25upx;">是否为默认付款方式：{{is_default1=='1'?'是':'否'}}</view>
				<button class="colorfff sysbj font34 btn_sub" @click="xgBtn">修改</button>
			</view>
		</view>
		
		
		
		
	</view>
</template>

<script>
	import uniIcon from '../../../components/uni-icon/uni-icon.vue' //图标
	export default {
		data() {
			return {
				userName:'',
				userNumber:'',
				
				flag1:true,
				is_default1:''
			};
		},
		onLoad() {
			this.getstatus()
		},
		onShow(){
			// this.getstatus()
		},
		components:{
			uniIcon
		},
		methods:{
			 reback(){ //返回
				uni.navigateTo({
					url:"../my/pay_type"
				})
			},
			addCard(){
				uni.navigateTo({
					url:'./addCard'
				})
			},
			xgBtn(){
				uni.navigateTo({
					url:'./addCard'
				})
			},
			// 获取绑定状态
			getstatus(){
				//发送请求
				uni.request({
					url:this.$HttpHead+'user/get_user_bank',
					data:{
						uid:uni.getStorageSync('udata').uid,
						token:uni.getStorageSync('udata').token,
					},
					header: {'content-type': 'application/x-www-form-urlencoded'},
					method:'POST',
					success:(res)=>{
						console.log(res)
						if(res.data.status=="ok"){
							for(let i=0;i<res.data.data.length;i++){
								
								if(res.data.data[i].type=='1'){
									this.flag1=false;
									console.log(this.flag1)
									this.userName=res.data.data[i].bank_name;
									this.userNumber=res.data.data[i].bank_number;
									this.qrcode=res.data.data[i].qrcode;
									this.is_default1=res.data.data[i].is_default;
									break;
								}else{
									this.flag1=true;
								}
							}
						
						}else if(res.data.status=="error"){
							if(res.data.errormsg=="token验证失败"){
								uni.showToast({
									title:'您的账号在另一台设备正在登录',
									icon:"none",
									duration:1500
								});
								setTimeout(function(){
									uni.navigateTo({
										url:'../login/login'
									})
									
								},2000)
							}else{
								console.log(res.data.errormsg)
								/* uni.showToast({
									title:res.data.errormsg,
									icon:"none",
									duration:1500
								}); */
							}
						}
					}
				})
			},
			
		}
	}
</script>

<style lang="less">
	
	// 添加银行卡
	.addCard{
		width: 90vw;
		margin: 0 auto;
		border-radius: 15upx;
		padding: 15upx 0;
		margin-top: 50upx;
	}
	.overflow{
		overflow: hidden;
	}
	.name{
		display: flex;
		justify-content: space-between;
		padding:15upx 25upx;
		border-bottom: 1px solid #eee
	}
	.imag{
		display: flex;
		justify-content: center;
		padding: 30upx 0;
	} 
	.box{
		padding-bottom:25upx;
	}
	.btn_sub{
		
		width: 80vw;
		margin: 80upx auto;
	}
</style>
